import type { IRole } from '@/types/role'
import type { IPageParams } from '@/types/table'
import request from './request'

export function getRoles(params: IPageParams) {
  return request({
    url: 'admin/system/role/list',
    method: 'get',
    params,
    loading: true
  })

}

export function getRoleById(id: number) {
  return request({
    url: `/admin/system/role/info/${id}`,
    method: 'get'
  })
}

export function delRole(id: number) {
  return request({
    url: '/admin/system/role/delete',
    method: 'get',
    params: { id },
    loading: true
  })
}

export function saveRole(data: IRole) {
  return request({
    url: `/admin/system/role/${!data.id ? 'save' : 'update'}`,
    method: 'post',
    data,
    loading: true
  })
}
export function updateRoleStatus<T>(pram: any) {
  return request({
    url: '/admin/system/role/updateStatus',
    method: 'get',
    params: { id: pram.id, status: pram.status },
  })
}